Workflow Builder
The Workflow Builder is the primary way to create workflows in BindAI. It provides a fluent API for constructing workflow graphs by connecting nodes together in a readable and maintainable way. Instead of manually managing workflow objects and connections, the builder handles the structure for you.Why Use the Builder?
A workflow is fundamentally a graph. Managing nodes and connections manually quickly becomes difficult as workflows grow. The builder simplifies this process by allowing workflows to be constructed step by step.Builder Pattern
The builder follows a fluent interface. Conceptually:Creating a Builder
A workflow begins with a builder instance.Defining a Start Node
Every workflow begins with a start node.Adding Nodes
Nodes are added sequentially. Example:Fluent Chaining
Because the builder is fluent, workflows can also be written as a chain.Building the Workflow
When construction is complete:Validation
The builder automatically checks common workflow errors. Examples include:- missing start node
- unreachable nodes
- duplicate node identifiers
- invalid connections
- missing end node
Registering Agents
When an agent node is added, the builder automatically registers the agent with the workflow. Conceptually:Conditional Branches
Builders can create branching workflows. Conceptually:Loops
Loops allow sections of a workflow to repeat.Parallel Execution
Builders also support parallel branches.Human Tasks
Human approval can be inserted into a workflow.Variables
The builder does not manage workflow data directly. Instead, nodes communicate through workflow variables stored in the execution context.Large Workflows
As workflows become larger, organizing related sections together improves readability. Example structure:Best Practices
- Start with a clear workflow objective.
- Keep nodes focused on a single responsibility.
- Use fluent chaining for small workflows.
- Use intermediate variables for complex workflows.
- Validate workflows before deployment.
- Prefer multiple small workflows over one extremely large workflow.
- Separate orchestration logic from business logic.
